{% extends "admin/base.html" %}
{% block hscript %}
	<script type="text/javascript" src="themes/{{site.theme}}/style/jquery.min.js"></script>
    <script type="text/javascript" src="themes/{{site.theme}}/style/jquery.form.js"></script>
{% endblock %}
{% block nav %}
			<a href="?a=Tag">All Tags</a>
{% endblock %}
{% block content %}
<form action="?a=Tag" method="post" id="tagForm">
	<div class="wrap">
<h2>Edit tag</h2>
      <div id="poststuff">

<div id="submitlink" class="submitbox">

<div id="previewview">
</div>

<div class="inside">
<p>&nbsp;</p>
</div>

<p class="submit">
<input type="submit" id="btn-save" tabindex="3" value="Save" name="" class="button button-highlighted"/><br />
<input type="button" id="btn-del" tabindex="4" value="Delete" onclick="doDel({{tag.id}})" class="button button-highlighted"/>
</p>
</div>

<div id="post-body">
<div class="stuffbox">
<h3>Name</h3>
<div class="inside">
	<input type="text" id="name" value="{{tag.name}}" tabindex="1" size="30" name="name"/>
</div>
</div>

<div class="stuffbox">
<h3>Slogan</h3>
<div class="inside">
	<input type="text" id="slogan" value="{{tag.slogan}}" tabindex="2" size="30" name="slogan"/>
</div>
</div>

<input type="hidden" value="{{tag.id}}" name="id"/>
<input type="hidden" value="update" name="d"/>

</div>
</div>	
	</div>
</form>
{% endblock %}
{% block bscript %}    
<script type="text/javascript">
    $(document).ready(function() { 
    	var options = {
    	    	dataType: 'json',
    	    	success : function(data) {
	    				var hmd = $("#hiddenMessage");
	    				if (data.type == "error") {
	    					hmd.html("<div class='error'>" + data.message + "</div>");
	    				} else {
	    					hmd.html("<div class='info'>" + data.message + "</div>"); 
	    				}
	    				hmd.show().focus();
    				},
    	};
    	$("#tagForm").ajaxForm(options);
    });

    function doDel(id) {
     	$.ajax({
     		type: "GET",
     		url: "?a=Tag&d=delete&id=" + id,
     		dataType: "json",
     		success: function(data){
     			var hmd = $("#hiddenMessage");
    	    	if (data.type == "error") {
    	    		hmd.html("<div class='error'>" + data.message + "</div>");
    	    	} else {
    	    		hmd.html("<div class='info'>" + data.message + "</div>");
    	    	}
    	    	hmd.show().focus();
    	    	$("#btn-save").hide();
    	    	$("#btn-del").hide();
     		}
     	});
    }    
</script>
{% endblock %}